package uk.ac.ebi.uniprot.wikipedia.model;

/**
 * Created with IntelliJ IDEA.
 * User: ljgarcia
 * Date: 13/06/12
 * Time: 10:11
 * To change this template use File | Settings | File Templates.
 */
public class GeneWikiConflictPage extends GeneWikiPage {

    public GeneWikiConflictPage(GeneWikiPage gw) {
        this.accession = gw.accession;
        this.wikiURL = gw.wikiURL;
        this.geneId = gw.geneId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;

        GeneWikiConflictPage that = (GeneWikiConflictPage) o;

        if (this.accession != null ? !accession.equals(that.accession) : that.accession != null) return false;
        if (!this.geneId.equals(that.geneId)) return false;
        if (!this.wikiURL.equals(that.wikiURL)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + wikiURL.hashCode();
        result = 31 * result + (accession != null ? accession.hashCode() : 0);
        result = 31 * result + geneId.hashCode();
        return result;
    }

    @Override
    public int compareTo(GeneWikiPage o) {
        if (this.equals(o)) {
            return 0;
        }
        String tempAcc = this.accession == null ? "" : this.accession;
        String otherTempAcc = o.accession == null ? "" : o.accession;
        return (this.wikiURL+this.geneId+tempAcc).compareTo(o.wikiURL+o.geneId+otherTempAcc);
    }
}
